package com.java.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.java.model.*;
import com.java.service.*;
import com.java.utils.CommonUtils;
import com.java.utils.JsonBody;
import com.java.utils.ResponseUtil;;

@RestController
@RequestMapping("/introduce")
public class IntroduceController {
	private IntroduceService introduceService;

	public IntroduceService getIntroduceService() {
		return introduceService;
	}

	@Autowired
	public void setIntroduceService(IntroduceService introduceService) {
		this.introduceService = introduceService;
	}

	@Autowired
	private HttpServletRequest request;
	@Autowired
	private HttpServletResponse response;

	@CrossOrigin(origins = "*")
	@ResponseBody
	@RequestMapping("edit")
	public JsonBody edit(@RequestBody Introduce intr) {
		if(introduceService.Edit(intr)>0)
			return Util.SetMap("修改成功",true);
		else
			return Util.SetMap("修改失败",false);
	}

	@CrossOrigin(origins = "*")
	@ResponseBody
	@RequestMapping("list")
	public JsonBody list() {
		return Util.SetData(introduceService.Get(), "");
	}



	@CrossOrigin(origins = "*")
	@ResponseBody
	@RequestMapping("getbyid")
	public JsonBody getbyid(int id) {
		return Util.SetData(introduceService.GetByID(id), "");
	}


}
